"""The application's model objects"""
import sqlalchemy as sa
from sqlalchemy import orm

from papyrus.model import meta


def init_model(engine):
    """Call me before using any of the tables or classes in the model"""
    ## Reflected tables must be defined and mapped here
    #global reflected_table
    #reflected_table = sa.Table("Reflected", meta.metadata, autoload=True,
    #                           autoload_with=engine)
    #orm.mapper(Reflected, reflected_table)
    #
    meta.Session.configure(bind=engine)
    meta.engine = engine

# Import all SQLAlchemy models. This makes all models available under
# papyrus.model and it makes SA mappers compile correctly as all relations are
# string based, not object based. This prevents from circual import problems.
from papyrus.model.auth import User, Group, Permission
from papyrus.model.blog import Article, Comment
